<?php
    if( isset( $errorsModel ) && $errorsModel instanceof ErrorsModelVO )
    {
        $manager = new ErrorsModelManager( $errorsModel );
    }
    if( isset( $result ) ) $result instanceof MediaVO;
?>
<div id="title_bloc" class="app_contents">
    <h1>Gestion des Média de l'application <strong>: MEDIA</strong></h1>
</div>

<div id="description_bloc">
    Formulaire d'édition d'un média.
</div>

<?php $this->config->includePartial( BackendModulesList::MAIN, 'flashes', array( 'flashes' => $flashes ) ) ;?>

<?php echo HtmlHelper::form( UriHelper::get( BackendModulesList::MEDIA, BackendActionsList::EDIT ), array( 'id' => 'mediaEditForm' ), true ) ;?>

    <?php echo HtmlHelper::hidden( MediaModel::ID_FIELD, $result->id ); ?>

    <label for="label">Label</label><?php echo HtmlHelper::inputText( MediaModel::LABEL_FIELD, array( 'id' => 'media_label', 'value' => $result->label ) ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( MediaModel::LABEL_FIELD ) ): ?><?php echo HtmlHelper::errorForm( $manager->getError( MediaModel::LABEL_FIELD )->message ); ?><br /><?php endif; ?>

    <?php if( file_exists( UPLOADS_PATH . 'media/' . $result->file ) ):?>
        <?php echo HtmlHelper::image( '/uploads/media/' . $result->file, $result->file, array( 'height' => 150 ) );?>
    <?php endif;?>
    <label for="file">File</label><?php echo HtmlHelper::file( MediaModel::FILE_FIELD, array( 'id' => 'media_file' ) ) ; ?><br />
    <?php echo HtmlHelper::hidden( MediaModel::FILE_FIELD, $result->file ); ?>
    <?php if( isset( $manager ) && $manager->hasError( MediaModel::FILE_FIELD ) ): ?><?php echo HtmlHelper::errorForm( $manager->getError( MediaModel::FILE_FIELD )->message ); ?><br /><?php endif; ?>

    <label for="startAt">Start at</label><?php echo HtmlHelper::dateTime( MediaModel::START_AT_FIELD, $years, array(), false, $result->startAt ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( MediaModel::START_AT_FIELD ) ): ?><?php echo HtmlHelper::errorForm( $manager->getError( MediaModel::START_AT_FIELD )->message ); ?><br /><?php endif; ?>

    <label for="EndAt">End at</label><?php echo HtmlHelper::dateTime( MediaModel::END_AT_FIELD, $years, array(), false, $result->endAt ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( MediaModel::END_AT_FIELD ) ): ?><?php echo HtmlHelper::errorForm( $manager->getError( MediaModel::END_AT_FIELD )->message ); ?><br /><?php endif; ?>

    <span class="submit"><?php echo HtmlHelper::submit( array( 'name' => 'submit', 'value' => 'Mettre à jour le média' ) ) ; ?></span>
</form>